#include <stdio.h>
#include <math.h>

int div10(int n)
{
    int tmp=n;
    while (tmp%10==0)
    {
        tmp=tmp/10;
    }
    return tmp;
}


int getEndNum(int n)
{
    int tmp=n%10;
    while (tmp==0)
    {
        n=n/10;
        tmp=n%10;
    }
    return tmp;
}



int main(){
    int i,n;
    scanf("%d",&n);
    double l5=log(n)/log(5)+0.05;
    int max=(int)(l5);

    //保存下2的n次分 最后计算
    int num=0;
    int result=1;
    for(i=2;i<=n;i++)
    {
        int tmp=div10(i);
        if(tmp%2==0)
        {
            while (num<max&&tmp%2==0)
            {
                tmp=tmp/2;
                num++;
            }
        }
        else if (tmp%5==0)
        {
            while (tmp%5==0)
            {
                tmp=tmp/5;
                num--;
            }
        }
        
        result=getEndNum(getEndNum(tmp)*result);
    }
    for(i=0;i<num;i++)
    {
        result=result*2;
    }
    result=getEndNum(result);

    printf("%d\n",result);
    return 0;
}